<%@ page import="java.util.Map" %>
<%@ page import="java.util.List" %>
<%@ page import="com.car.dao.DB" %>
<%@ page import="com.car.service.UserService" %>
<%@ page import="com.car.entyti.User" %>
<%--
  Created by IntelliJ IDEA.
  User: 16937
  Date: 2021/5/23
  Time: 12:28
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>

<body>
<ul class="layui-nav " style="display: flex">
    <div style="flex: 1"></div>
    <div style="flex: 4">
        <li class="layui-nav-item"><a href="<%=request.getContextPath()%>/index.jsp">主页</a></li>
        <li class="layui-nav-item "><a href="<%=request.getContextPath()%>/index.jsp">长途拼车</a></li>
        <li class="layui-nav-item"><a href="">拼车关注 </a></li>
        <li class="layui-nav-item">
            <a href="javascript:;">解决方案</a>
            <dl class="layui-nav-child"> <!-- 二级菜单 -->
                <dd><a href="">移动模块</a></dd>
                <dd><a href="">后台模版</a></dd>
                <dd><a href="">电商平台</a></dd>
            </dl>
        </li>
        <li class="layui-nav-item"><a href="">社区</a></li>
    </div>
    <div style="flex: 4"></div>
    <%--11--%>
    <div style="flex: 2">
        <li class="layui-nav-item">
            <a href="<%=request.getContextPath()%>/Carpool_info.jsp">发布拼车<span class="layui-badge-dot"></span></a>
        </li>

        <li class="layui-nav-item">
            <a  style="display: inline-block" href="">
                <%
                    Cookie[] cookies = request.getCookies();
                    String token = null;

                    if (cookies != null) {
                        for (Cookie cookie : cookies) {
                            if (cookie.getName().equals("TOKEN")) {
                                token = cookie.getValue();
                            }
                        }
                    }

                    if (token == null) {
                        out.print("<span> <a style='display: inline-block' href=\"login.jsp\">登录</a></span>");

                    } else {
                        UserService userService = new UserService();
                        User user = userService.getUserByToken(token);
                        if (user != null) {
                            out.print(" <img style=\"display: inline-block\" src=\"//t.cn/RCzsdCq\" class=\"layui-nav-img\">");
                            out.print(" <span style = 'color: red' >" + user.getName() + "</span>");
                        }
                    }
                %>
            </a>
            <dl class="layui-nav-child">
                <dd><a  href="User.jsp">个人中心</a></dd>
                <dd><a href="javascript:;"></a></dd>
                <dd><a href="login.jsp">退出登录</a></dd>
            </dl>
        </li>

    </div>
    <div style="flex: 1"></div>
</ul>
</body>
</html>
